@extends('layouts.back_stage')
@section('content')
    <style>
        .address {
            border-color: #cfdadd;
            border-radius: 2px;
            width: 25%;
            height: 30px;
            padding: 6px 10px;
            font-size: 12px;
            line-height: 1.42857143;
            margin-right:10px;
            color: #555;
            background-color: #fff;
            background-image: none;
            border: 1px solid #cfdadd;
            box-shadow: none;
            -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
            -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
        }
        table,th,td{text-align: center}
        h3{display:inline-block;}
    </style>
    <div class="container">
        <div style="padding:20px 0;">
            <h3>工单列表</h3>
            <div style="float:right;">
                <span>工单提醒：</span>
                <a style="margin-right:5px;cursor:default;" href="JavaScript:;">未处理({{$no_deal}})</a>
                <a style="cursor:default;" href="JavaScript:;">待确认结单({{$had_deal}})</a>
            </div>
        </div>
        <div class="pull-left" style="width: 100%;margin-bottom: 20px">
            <form action="/work-order/work-order-lists"  method="get" role="form" style="display: inline-block;margin-right: 10px">
                <label>工单类型：</label>
                <select name="type" class="address" style="width: 150px">
                    <option value="">请选择</option>
                    <option value="1">退换货</option>
                </select>
                <label>工单状态：</label>
                <select name="status" class="address" style="width: 150px">
                    @if(isset($req->status))
                        <option value="{{$req->status}}">
                        @if($req->status==1)
                            未处理
                        @elseif($req->status==2)
                            处理中
                        @elseif($req->status==3)
                            已处理
                        @endif
                        </option>
                     @endif
                    <option value="">请选择</option>
                    <option value="1">未处理</option>
                    <option value="2">处理中</option>
                    <option value="3">已处理</option>
                </select>
                <label>工单进度：</label>
                <select name="pro_status" class="address" style="width: 150px">
                    @if(isset($req->pro_status))
                        <option value="{{$req->pro_status}}">
                            @if($req->pro_status==1)提交工单
                            @elseif($req->pro_status==2)接收工单
                            @elseif($req->pro_status==4)已收货
                            @elseif($req->pro_status==6)质检完成
                            @elseif($req->pro_status==7)换货
                            @elseif($req->pro_status==8)已发货
                            @elseif($req->pro_status==9)退款
                            @elseif($req->pro_status==10)已退款
                            @elseif($req->pro_status==11)已结单
                            @endif
                        </option>
                    @endif

                    <option value="">请选择</option>
                    <option value="1">提交工单</option>
                    <option value="2">接收工单</option>
                    <option value="4">已收货</option>
                    <option value="6">质检完成</option>
                    <option value="7">换货</option>
                    <option value="8">已发货</option>
                    <option value="9">退款</option>
                    <option value="10">已退款</option>
                    <option value="11">已结单</option>
                </select>
                <label>提交人:</label>
                <input class="address" style="width: 150px" type="text" name="submitter" autocomplete="off" autocorrect="off" placeholder="请输入提交人" value="{{$req->submitter}}">
                <label>客户姓名:</label>
                <input class="address" style="width: 150px" type="text" name="customer_name" autocomplete="off" autocorrect="off" placeholder="请输入用户名" value="{{$req->customer_name}}">
                <button type="submit" class="btn btn-info" style="margin-bottom:4px;">搜索</button>
            </form>
        </div>
        <table class="table table-hover data-table">
            <thead>
            <tr>
                <th class="text-center">提交人</th>
                <th class="text-center">客户姓名</th>
                <th class="text-center">联系方式</th>
                <th class="text-center">类型</th>
                <th class="text-center">状态</th>
                <th class="text-center">问题描述</th>
                <th class="text-center">操作人(销售/仓库)</th>
                <th class="text-center">进度</th>
                <th class="text-center">提交时间</th>
                <th class="text-center">操作</th>
            </tr>
            </thead>
            <tbody>
            @if(count($infos)>0)
                @foreach($infos as $k => $v)
                    <tr >
                        <td>{{$v->submitter}}</td>
                        <td>{{$v->customer_name}}</td>
                        <td>{{$v->customer_tel}}</td>
                        <td>@if($v->type==1)退/换货 @else 其它@endif</td>
                        <td>
                            @if($v->status==1)未处理
                            @elseif($v->status==2)处理中
                            @elseif($v->status==3)已处理
                            @else未知状态
                            @endif
                        </td>
                        <td>{{mb_substr($v->description,0,4)}}...</td>
                        <td>{{$v->seller or '-'}}/{{$v->storekeeper or '-'}}</td>
                        <td>
                            @if($v->pro_status==-1)未寄出
                            @elseif($v->pro_status==1)已提交工单
                            @elseif($v->pro_status==2)已接收工单
                            @elseif($v->pro_status==3)仓库待收货
                            @elseif($v->pro_status==4)仓库已收货
                            @elseif($v->pro_status==5)质检中
                            @elseif($v->pro_status==6)质检完成
                            @elseif($v->pro_status==7)换货中
                            @elseif($v->pro_status==8)已发货
                            @elseif($v->pro_status==9)退款中
                            @elseif($v->pro_status==10)已退款
                            @elseif($v->pro_status=11)已结单
                            @endif

                        </td>
                        <td>{{$v->created_at}}</td>
                        <td><a href="/work-order/work-order-chat?id={{$v->id}}">详情</a></td>
                    </tr>
                @endforeach
            @endif
            </tbody>
        </table>
        <div style="float: right">{{$infos->appends(['type'=>$req->type,'status'=>$req->status,'pro_status'=>$req->pro_status,'submitter'=>$req->submitter,'customer_name'=>$req->customer_name])->links()}}</div>
    </div>
    <script>
        window.onload=function(){
            var url = window.location.href;
            if(url.indexOf("tn=1") >= 0 ) {
                $(".order_li").addClass('active').siblings().removeClass('active');
                $(".order_li").children('.nav-second-level').addClass('in').parent().siblings().children('.nav-second-level').removeClass('in');
            }
            var num=$(".order_li.item-li").index();
            sessionStorage.setItem('Number',num);
        }
    </script>
@endsection